$(function() {
	var url=null;
	var operation = {// 操作按钮  调取url
			addFun : rootPath + '/productinfo/addUI.shtml',
			editFun: rootPath + '/productinfo/editUI.shtml?id=',
			delFun : rootPath + '/productinfo/deleteEntity.shtml',
			editdropdownFun :rootPath + '/productdropdown/productdropdownList.shtml?id='
		}
	$.ajax({
		url:rootPath + '/productinfo/getButton.shtml',//请求获取按钮
		success:function(data){
			var button = data;
			grid = TableData({
				gaine : 'paging',//id名
				table: 'productinfo',
				column : [ {
					colkey : "colName",
					name : "字段名称",
				}, {
					colkey : "type",
					name : "字段类型",
					"orderable": true,
					render:function(data,type,row,meta){
						switch (data){
							case 1:
								return '文本框';
								break;
							case 2:
								return '下拉框';
								break;
							case 3:
								return '日期';
								break;
						}
					}
				}, {
					colkey : "isDropdown",
					name : "是否下拉取值",
					"orderable": true,
					render:function(data,type,row,meta){
						switch (data){
							case 0:
								return '否';
								break;
							case 1:
								return '是';
								break;
						}
					}
				}, {
					colkey : "must",
					name : "是否必填",
					"orderable": true,
					render:function(data,type,row,meta){
						switch (data){
							case 0:
								return '否';
								break;
							case 1:
								return '是';
								break;
						}
					}
				},{
					colkey : "defaultValue",
					name : "默认值",
				}, {
					colkey : "inputseq",
					name : "排列顺序",
				},{
					colkey : "sysfields",
					name : "是否系统字段",
					"orderable": true,
					render:function(data,type,row,meta){
						switch (data){
							case 0:
								return '否';
								break;
							case 1:
								return '是';
								break;
						}
					}
				}, {
					colkey : "promptContent",
					name : "提示信息",
				}, {
					colkey : "operation",
					name : "操作",
					"orderable": false,
					render:function(data,type,row,meta){
						if(button !== ''){
							  button = button.replace("\"","");
							  button = button.replace("\"","");
					        }
						return button;
					}
				} ],
				url : rootPath + '/productinfo/findByPage.shtml',//表格数据请求地址
				success:function(){
					//将事件绑定在body上
					productinfo = function(e){
					    var e = e||window.event;
					    var target = $(e.target || e.srcElement);
					    //新增
					    if(target.hasClass('addFun')){
					    	cover._Body();//防止多次点击
					    	var id = target.parent().parent().attr('dataid');
					    	_click(operation.addFun,'addFun',id)
					    }
					    // 编辑
					    if(target.hasClass('editFun')){
					    	cover._Body();//防止多次点击
					    	var id = target.parent().parent().attr('dataid');
					    	_click(operation.editFun,'editFun',id)
					    }
					   //  删除
					    if(target.hasClass('delFun')){
					    	cover._Body();//防止多次点击
					    	var id = target.parent().parent().attr('dataid');
					    	_click(operation.delFun,'delFun',id)
					    }
					    // 下拉选择
					    if(target.hasClass('editdropdownFun')){
					    	cover._Body();//防止多次点击
					    	var id = target.parent().parent().attr('dataid');
					    	_click(operation.editdropdownFun,'editdropdownFun',id)
					    }
				  }
				  $("#productinfo_wrapper").off("click", productinfo);
				  $("#productinfo_wrapper").on('click', productinfo);
				}
			 });
		}
	})
	 
});
	
	